#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,n) for(int i=a;i<n;++i)

using namespace std;

class SuffixTree
{
public:
    static const int MAXN = 100*2;
    static const int inf = 1<<29;
    static const int HASHN = 3;
    struct Node
    {
        Node *nextSuffix,*parent;
        vector<pair<char,Node*> > nextNode[HASHN];
        typedef vector<pair<char,Node*> >::iterator listItr;
        int startPos,endPos;//[startPos,endPos) of str
        int preLength;
        inline Node* getNext(char c)
        {
            int pos = c%HASHN;
            for(listItr i = nextNode[pos].begin();i!=nextNode[pos].end();i++) if(i->first==c)
                return i->second;
            return NULL;
        }
        inline void addNext(char c,Node *nt)
        {
            int pos = c%HASHN;
            for(listItr i = nextNode[pos].begin();i!=nextNode[pos].end();i++) if(i->first==c)
            {
                i->second=nt;
                return ;
            }
            nextNode[pos].push_back(make_pair(c,nt));
        }
        void init(int a,int b)
        {
            REP(i,HASHN) nextNode[i].clear();
            startPos = a, endPos = b;
            nextSuffix = NULL;
            preLength = 0;
        }
        inline int length()
        {
            return endPos - startPos;
        }
    };
    struct ActiveNode
    {
        Node *node;
        int endPos;//将要比较的位置
        ActiveNode(Node *nt,int t)
        {
            node = nt;
            endPos = t;
        }
        bool isExplicit()
        {
            return node->endPos == endPos;
        }
    };
    Node *root;
    Node *nodes,*np;
    string str;
    SuffixTree()
    {
        nodes = new Node[MAXN];
        clear();
    }
    void clear()
    {
        np = nodes;
        root = newNode(0,0);
        root->nextSuffix = root;
    }
    Node* newNode(int stP,int edP)
    {
        np->init(stP,edP);
        return np++;
    }
    void link(Node *na,Node *nb)
    {
        char c = str[nb->startPos];
        na->addNext(c,nb);
        nb->parent = na;
        nb->preLength = na->preLength + na->length();
    }
    inline void nextActiveNode(ActiveNode &acNode,Node *&lastExplicitNode,
                        int &suffixStartPos,int &suffixEndPos,string &s)
    {
        lastExplicitNode = lastExplicitNode->nextSuffix;
        Node *nt = lastExplicitNode;
        int len = suffixEndPos - suffixStartPos;
        int tlen ;
        while((tlen=nt->preLength+nt->length())<len)
        {
            char c =  s[suffixStartPos+tlen];
            lastExplicitNode = nt;
            nt = nt->getNext(c);
        }
        acNode.node=nt;
        acNode.endPos = nt->startPos+(len-nt->preLength);
    }
    void build(string s)
    {
        str = s;
        int suffixStartPos = 0;
        ActiveNode acNode(root,0);
        Node *lastExplicitNode = root;
        REP(i,str.size())
        {

            int curPos = i;
            char c = str[curPos];
            Node *lastNode = root;
            while(true)
            {
                Node *curNode = acNode.node;
                if(acNode.isExplicit())
                {
                    lastExplicitNode = acNode.node;
                    Node *nt = curNode->getNext(c);
                    if(!nt)  link(curNode,newNode(curPos,inf));
                    else
                    {

                        acNode.node = nt;
                        acNode.endPos = acNode.node->startPos+1;
                        break;
                    }
                }
                else
                {
                    if(str[acNode.endPos]!=c)
                    {
                        Node *parent = curNode->parent;
                        Node *nt = newNode(curNode->startPos,acNode.endPos);
                        curNode->startPos = acNode.endPos;
                        link(parent,nt);
                        link(nt,curNode);
                        link(nt,newNode(curPos,inf));
                        curNode = nt;
                    }
                    else
                    {
                        acNode.endPos++;
                        break;
                    }
                }
                if(lastNode!=root)  lastNode->nextSuffix = curNode;
                lastNode = curNode;
                if(curPos == suffixStartPos++) break;
                nextActiveNode(acNode,lastExplicitNode,suffixStartPos,curPos,str);
            }
            if(lastNode!=root) lastNode->nextSuffix = acNode.node->parent;
        }
    }
    int lcs(string s)
    {
        ActiveNode acNode(root,0);
        int suffixStartPos = 0;
        Node *lastExplicitNode = root;
        int dep = -inf;
        REP(i,s.size())
        {
            int curPos = i;
            char c = s[curPos];
            while(true)
            {
                Node *curNode = acNode.node;
                dep = max(dep,curNode->preLength+acNode.endPos - curNode->startPos);
                if(acNode.isExplicit())
                {
                    lastExplicitNode = acNode.node;
                    if(Node *nt=curNode->getNext(c))
                    {
                        acNode.node = nt;
                        acNode.endPos = acNode.node->startPos+1;
                        break;
                    }
                }
                else
                {
                    if(str[acNode.endPos]==c)
                    {
                        acNode.endPos++;
                        break;
                    }
                }
                if(curPos == suffixStartPos++) break;
                nextActiveNode(acNode,lastExplicitNode,suffixStartPos,curPos,s);
            }
        }
        return dep;
    }
};
SuffixTree tree;
char ss[100100];
int main()
{
    freopen("in.txt","r",stdin);
    scanf("%s",ss);
    tree.build(string(ss)+char('a'+27));
    scanf("%s",ss);
    cout<<tree.lcs(string(ss)+char('a'+28))<<endl;
    return 0;
}
